package com.zyl.musicdemo.activitys;

import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zyl.musicdemo.R;
import com.zyl.musicdemo.bean.MusicModel;
import com.zyl.musicdemo.view.PlayMusicView;

import de.hdodenhof.circleimageview.CircleImageView;

import static com.zyl.musicdemo.adapter.SongAdapter.SONG_BEAN;

public class PlayMusicActivity extends BaseActivity {

    ImageView ivBack, ivBackground;
    TextView tvAuthor, tvSongName;
    PlayMusicView playMusicView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_music);

        //        隐藏statusBar
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        initView();
    }

    private void initView() {
        ivBack = findViewById(R.id.iv_back);
        ivBackground = findViewById(R.id.iv_background);
        tvAuthor = findViewById(R.id.tv_author);
        tvSongName = findViewById(R.id.tv_song_name);
        playMusicView = findViewById(R.id.play_music_view);

        MusicModel musicModel = (MusicModel) getIntent().getSerializableExtra(SONG_BEAN);
        tvAuthor.setText(musicModel.getAuthor());
        tvSongName.setText(musicModel.getName());
        Glide.with(this)
                .load(musicModel.getPoster())
                .into(ivBackground);

        playMusicView.setMusic(musicModel);
        playMusicView.playMusic();

        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        playMusicView.destroy();
    }
}